package com.android.canvasproject.adapter;

import java.util.List;

import com.android.canvasproject.R;
import com.android.canvasproject.model.entity.Person;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class DetailPersonDrawerAdapter extends BaseAdapter {
	
	private Context context;
	private List<Person> personListDrawer;
	
	public DetailPersonDrawerAdapter(Context ctx, List<Person> personList) {
		context = ctx;
		personListDrawer = personList;
	}

	@Override
	public int getCount() {
		return personListDrawer.size();
	}

	@Override
	public Object getItem(int position) {
		return personListDrawer.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null){
			LayoutInflater inflaterLayout = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
			convertView = inflaterLayout.inflate(R.layout.drawer_person, null);
		}

		//INFORMAÇÕES DO PERFIL
		ImageView imageProfile = (ImageView) convertView.findViewById(R.id.profile_image);
		TextView profileName = (TextView) convertView.findViewById(R.id.profile_name);
		TextView profileOccupation = (TextView) convertView.findViewById(R.id.profile_occupation);
		TextView profileLocal = (TextView) convertView.findViewById(R.id.profile_local);

		//INFORMAÇÕES PROFISSIONAIS
		TextView academicTraining = (TextView) convertView.findViewById(R.id.academic);
		TextView teachingInstitution = (TextView) convertView.findViewById(R.id.institution);
		TextView professionalOccupation = (TextView) convertView.findViewById(R.id.professional_occupation);
		TextView businessJob = (TextView) convertView.findViewById(R.id.business_job);
		TextView periodJob = (TextView) convertView.findViewById(R.id.period_job);
		TextView localJob = (TextView) convertView.findViewById(R.id.local_job);
		TextView descriptionJob = (TextView) convertView.findViewById(R.id.description_job);

		//INFORMAÇÕES GERAIS 
		TextView since = (TextView) convertView.findViewById(R.id.since);
		TextView lastAccessed = (TextView) convertView.findViewById(R.id.last_accessed);

		imageProfile.setImageResource(R.drawable.exec);
		profileName.setText(personListDrawer.get(position).getName());
		profileOccupation.setText(personListDrawer.get(position).getOccupation());
		profileLocal.setText(personListDrawer.get(position).getLocationLastJob());

		academicTraining.setText(personListDrawer.get(position).getAcademicTraining());
		teachingInstitution.setText(personListDrawer.get(position).getTeachingInstitution());
		professionalOccupation.setText(personListDrawer.get(position).getOccupation());
		businessJob.setText(personListDrawer.get(position).getEnterprise());
//		periodJob.setText(personListDrawer.get(position).getStartingLastJob().toString() + " - " + personListDrawer.get(position).getEndingLastJob().toString());
		periodJob.setText("01/06/2011 - 30/03/2013");
		localJob.setText(personListDrawer.get(position).getLocationLastJob());
		descriptionJob.setText(personListDrawer.get(position).getDescriptionLastActivity());

		since.setText("20/10/2013");
		lastAccessed.setText("05/01/2014");

		return convertView;
	}
}